﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SaunaServer.Model.Network;
using SaunaServer.Controller.Communication;
using SaunaServer.View;

namespace SaunaServerUnitTest
{
    [TestClass]
    public class UnitTestTcpDaoGateway
    {
        private ITcpFactory tcpFactory;
        private ITcpDaoGatewayServer tcpDao;
        private const string TCP_SSL = "TcpSsl";
        NetworkSetting networkSetting = null;
        CommunicationManager communicationManager;
        private string CONFIG_DIR_FILE_NAME = @"G:\JCU_Y2_SP2\Software Engineering - CP2013\SourceCode\CommunicationServer\CommunicationServer\bin\Debug\SaunaConfig.ini";

        [TestMethod]
        public void TestReadTcpBaseSetting()
        {
            // Create Communication Manager
            communicationManager = new CommunicationManager(new CommunicationServerForm());

            // Read Sauna configuration file and create network setting
            networkSetting = communicationManager.ReadConfigFileFromDirectory(CONFIG_DIR_FILE_NAME);
            Assert.IsNotNull(networkSetting);
        }

        [TestMethod]
        public void TestCreateTcpDaoConnection()
        {
            TestReadTcpBaseSetting();

            // Create TCP DAO
            tcpFactory = new TcpFactoryImplementation();
            tcpDao = tcpFactory.Make(TCP_SSL, communicationManager, networkSetting);
            Assert.IsNotNull(tcpDao);
        }

    }
}
